<?php

remove();
function index() {
	user_array_change_key_case();
	$array = Array("编号1" => "测试1", "编号2" => "测试2", "编号3" => "测试3", );

}

/**
 *
 * 数组添加值
 *
 */
function add() {
	$array = array();
	//1、只添加值，不添加索引
	array_push($array, "4", "测试4");
	//添加数组元素
	array_push($array, array(1, 2, 3));
	//2、添加值和索引
	$array["编号4"] = "测试4";
	print_r($array);

}

function remove(){
	$array = array("id"=>1,"username"=>"admin","password"=>"123456");
	print_r($array);
	unset($array["id"]);
	print_r($array);
}

function user_array_change_key_case() {
	$array = array('A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D');
	print_r($array);
	$array = array_change_key_case($array, CASE_LOWER);
	print_r($array);
}

/**
 * 将array转化为json
 */
function toJson() {
	$array = array('A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D');
	print_r($array);
	$json = json_encode($array);
	print_r($json);

	// $arrays=array(
	// 0=>$array,
	// 1=>$array,
	// 2=>$array
	// );
	//将二维数组转化为json数组
	$arrays = array($array, $array, $array);

	print_r($arrays);
	$jsons = json_encode($arrays);
	print_r($jsons);

}

function fromJson() {
	$json='{"id":1,"username":"admin"}';
	//对象json默认转化为php对象
	$obj=json_decode($json);
	//true表示转化为php数组
	$a=json_decode($json,true);
	print_r($obj);
	//访问对象的属性
	print_r($obj->id);
	
	$json2='[1,"admin"]';
	$array=json_decode($json2);
	print_r($array);
}
?>